package com.example.springbott.wx_controller;

import com.example.springbott.bean.BaseRespVo;
import com.example.springbott.bean.MarketFeedback;
import com.example.springbott.bean.MarketUser;
import com.example.springbott.wx_service.WXFeedbackService;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 个人反馈中心
 *
 * @author silic xia
 * @since 2022/11/22 16:52
 */
@RestController
@RequestMapping("wx/feedback")
public class WXFeedbackController {

    @Autowired
    WXFeedbackService wxFeedbackService;

    /**
     *  意见反馈 feedback
     *
     * @param {"mobile":"13310000000","feedType":"商品相关","content":"产品有问,"hasPicture":true,
     * "picUrls":["http://182.92.235.201:8083/wx/storage/fetch/6t37wtmgzr5ljkjahs9m.jpeg"]}
     * 另外需要，username，userId
     *
     * @return {"errno":401,"errmsg":"参数不对"}
     *          {"errno":0,"errmsg":"成功"}
     * @author  silic xia
     * @since 2022/11/22 17:16
     */
    @RequestMapping("submit")
    public BaseRespVo wxFeedbackSubmit(@RequestBody MarketFeedback marketFeedback){
        MarketUser user = (MarketUser) SecurityUtils.getSubject().getPrincipal();
        wxFeedbackService.wxFeedbackSubmit(marketFeedback,user.getId(),user.getUsername());
        return BaseRespVo.ok();
    }
}

